package com.breakfast.fun.ui.user.recharge.rechargecard;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.breakfast.fun.R;
import com.breakfast.fun.base.BaseFragment;
import com.breakfast.fun.ui.user.recharge.rechargerecord.RechargeRecordActivity;
import com.breakfast.fun.util.T;

import butterknife.Bind;

/**
 * Created by Administrator on 2016/8/24.
 */
public class RechargeCardFragment extends BaseFragment<RechargeCardPresenter, RechargeCardModel> implements RechargeCardContract.View {
    @Bind(R.id.et_recharge_card)
    EditText mEtRechargeCard;
    @Bind(R.id.et_recharge_card_pwd)
    EditText mEtRechargeCardPwd;
    @Bind(R.id.btn_recharge_card_sure)
    Button mBtnRechargeCardSure;

    @Override
    public int getLayoutId() {
        return R.layout.fragment_recharge_card;
    }

    @Override
    public void initView() {
        mBtnRechargeCardSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mEtRechargeCard.getText().length() != 16) {
                    T.show("请输入16位充值卡号");
                    return;
                }
                if (mEtRechargeCardPwd.getText().length() != 6) {
                    T.show("请输入6位密码");
                }

                presenter.rechargeCard(mEtRechargeCard.getText().toString()
                        , mEtRechargeCardPwd.getText().toString());
            }
        });
    }

    @Override
    public void showSuccess() {
        T.show("充值成功");
        Intent intent = new Intent(getActivity(), RechargeRecordActivity.class);
        startActivity(intent);
    }

}
